package game;

import javax.swing.JOptionPane;

import boundaryToMatador.GUI;

public class GoToJail extends Field {

	public GoToJail(String name){
		this.name = name;
	}
	
	public void landOnField(Player player){
		
		System.out.println(" > " + player.getName() + " lander på DU FÆNGSLES! Og rykkes i fængsel.");
		
		player.setPosition(11);
		GUI.setCar(11, player.getName());
		player.setTurnsInJail(1);
	}
	
	public boolean isInJail(Player player){

		System.out.println("Game- Du er røget i fængsel!");
		System.out.println("Game- Account: " + player.getAccount().getPoint());
		
		int jailChoice = 0;
		int rollTimes = 0;
		int turnsInJail = player.getTurnsInJail();
		boolean inJail = true;
		
		Object[] possibleChoices = {"Betal dig ud af fængsel", "Vent"};
		jailChoice = JOptionPane.showOptionDialog(null, player.getName() + " det er din tur!\nHvad vil du gøre ?\n", player.getName(), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, possibleChoices, possibleChoices[0]);
		
		if(possibleChoices[0]== "Betal dig ud af fængsel"){
			inJail=false;
			player.setTurnsInJail(0);
	
			
			DiceCup.rollDice();
			
			player.movePlayer(DiceCup.getSum());
			GUI.removeCar(10, player.getName());
			GUI.setCar(player.getPosition(), player.getName());
			
			player.getAccount().addPoints(-1000);
			GUI.setBalance(player.getName(), player.getAccount().getPoint() );
		}
		
		else{
			inJail=true;
		player.setTurnsInJail(1);
		player.setPosition(11);
		GUI.setCar(player.getPosition(), player.getName());
	System.out.println("Game- InJail?: " + inJail);
		}
	return inJail;
	}

}